//
//  UserObj.m
//  FbeeAPP
//
//  Created by dev-m on 2018/3/25.
//  Copyright © 2018年 mohao. All rights reserved.
//

#import "UserObj.h"

@implementation UserObj

-(void)setObjByDict:(NSDictionary *)dict
{
    self.nickName = SafeGetStringValue([dict objectForKey:@"nickname"]);

    NSTimeInterval time = SafeGetDoubleValue([dict objectForKey:@"joinTime"])/1000.0f;
    NSDate *oDate = [NSDate dateWithTimeIntervalSince1970:time];
    NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
    NSTimeZone* destinationTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
    NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:oDate];
    NSInteger destinationGMTOffset = [destinationTimeZone secondsFromGMTForDate:oDate];
    NSTimeInterval interval = destinationGMTOffset - sourceGMTOffset;
    NSDate* currentDate = [[NSDate alloc] initWithTimeInterval:interval sinceDate:oDate];
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];// 创建一个时间格式化对象
    [dateFormatter setDateFormat:@"yyyy.MM.dd"];//设定时间格式,这里可以设置成自己需要的格式
    self.updateTime = [NSString stringWithFormat:@"%@ 加入",[dateFormatter stringFromDate:currentDate]];//将时间转化成字符串
}

@end
